export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
task_flag="jiayouzhan_noflip_L3base"                                # the task flag is used to identify folders.                         # checkpoint root for resume
index_file=/llmcapagroup1/test-bucket/liuxin/shiyout2i/prompt/L3train/加油站74_crop.json
resume=/llmcapagroup1/test-bucket/liuxin/hunyuantrainweightnew/L3train/018-datasetshuffle_batch2+batch3+batch4+oil7k+jiayouzhan194_size_multiscale_dit_g2_multiscale_L0base/checkpoints/0060000.pt/mp_rank_00_model_states.pt
results_dir=/gpfsprd/liuxin/hunyuantrainweightnew/L3/ipadapter                                      # save root for results
batch_size=3                                                 # training batch size
image_size=1024                                              # training image resolution
grad_accu_steps=2                                            # gradient accumulation
warmup_num_steps=0                                           # warm-up steps
lr=0.0001                                                    # learning rate
ckpt_every=2500                                         # create a ckpt every a few steps.
ckpt_latest_every=10000                                    # create a ckpt named `latest.pt` every a few steps.
ckpt_every_n_epoch=100                                         # create a ckpt every a few epochs.
epochs=1000                                                     # total training epochs

PYTHONPATH=. \
sh ./hydit/run_g_ipadapter.sh \
    --task-flag ${task_flag} \
    --noise-schedule scaled_linear --beta-start 0.00085 --beta-end 0.018 \
    --predict-type v_prediction \
    --reso-step 64 \
    --uncond-p 0.05 \
    --uncond-p-t5 0.05\
    --uncond-p-img 0.05\
    --index-file ${index_file} \
    --lr ${lr} \
    --batch-size ${batch_size} \
    --image-size ${image_size} \
    --global-seed 999 \
    --grad-accu-steps ${grad_accu_steps} \
    --warmup-num-steps ${warmup_num_steps} \
    --use-flash-attn \
    --use-fp16 \
    --use-ema \
    --resume-ema-root ${resume} \
    --extra-fp16 \
    --ema-dtype fp32 \
    --results-dir ${results_dir} \
    --reset-loader \
    --resume\
    --resume-module-root ${resume} \
    --epochs ${epochs} \
    --ckpt-every ${ckpt_every} \
    --ckpt-latest-every ${ckpt_latest_every} \
    --ckpt-every-n-epoch ${ckpt_every_n_epoch} \
    --log-every 10 \
    --deepspeed \
    --use-zero-stage 2 \
    --gradient-checkpointing \
    --no-strict \
    --training-parts ipadapter \
    --is-ipa True \
    --resume-ipa True \
    --resume-ipa-root /llmcapagroup1/jtcvdata/zky/code/HunyuanDIT-PRE-main/ckpts/t2i/model/ipa.pt  \
    --use-style-cond \
    --size-cond 1024 1024 \
    "$@"
